Cast String To Filter

I have a string which contains filter query i want to create filter on that string.

for example

string str = "(attribute \"Status\" == \"Done\" || attribute \"Status\" == \"Done2\")"
Filter f = str
here error comes , my requirement is to create filter based on string(Which contain query).

I tried various combinations but not able to create filter ,Please help me as soon as possible.
Thanks & Regards,
Hardik Shah
SystemAdmin - Mon Sep 06 07:35:21 EDT 2010

Re: Cast String To Filter
Mathias Mamsch - Mon Sep 06 08:22:51 EDT 2010

When your filter string is syntactically correct DXL code, a short solution is possible (although its a little magic):
 

bool setFilter (Module m, string filtStr) {
    string code = "Module m = addr_ " ((addr_ m) int) "\ncurrent=m\nFilter f = " filtStr"\n; set f"
        noError(); eval_ code; return (null lastError) 
}
 
string strOK = "(attribute \"Object Text\" == \"Done\" || attribute \"Object Heading\" == \"Done2\")"
 
print setFilter (current Module, strOK )

 


Unfortunately I get those error boxes with the "set(Filter)" function that I could not surpress using noError(). That topic has been discussed a lot of time in the past (search for "string filter" in the forum) and other solutions exist. So it might be worth checking them out. I thought this solution might add something new to the discussion.

Maybe that helps, Regards, Mathias

 

 

 


Mathias Mamsch, IT-QBase GmbH, Consultant for Requirement Engineering and D00RS

 

 

Re: Cast String To Filter
SystemAdmin - Mon Sep 06 10:18:00 EDT 2010

Mathias Mamsch - Mon Sep 06 08:22:51 EDT 2010

When your filter string is syntactically correct DXL code, a short solution is possible (although its a little magic):
 

bool setFilter (Module m, string filtStr) {
    string code = "Module m = addr_ " ((addr_ m) int) "\ncurrent=m\nFilter f = " filtStr"\n; set f"
        noError(); eval_ code; return (null lastError) 
}
 
string strOK = "(attribute \"Object Text\" == \"Done\" || attribute \"Object Heading\" == \"Done2\")"
 
print setFilter (current Module, strOK )

 


Unfortunately I get those error boxes with the "set(Filter)" function that I could not surpress using noError(). That topic has been discussed a lot of time in the past (search for "string filter" in the forum) and other solutions exist. So it might be worth checking them out. I thought this solution might add something new to the discussion.

Maybe that helps, Regards, Mathias

 

 

 


Mathias Mamsch, IT-QBase GmbH, Consultant for Requirement Engineering and D00RS

 

 

That works,
Thanks a lot....
Thanks & Regards,
Hardik Shah

Re: Cast String To Filter
Mathias Mamsch - Mon Sep 06 10:38:05 EDT 2010

SystemAdmin - Mon Sep 06 10:18:00 EDT 2010
That works,
Thanks a lot....
Thanks & Regards,
Hardik Shah

Can you set this thread to "answered" then? Regards, Mathias


Mathias Mamsch, IT-QBase GmbH, Consultant for Requirement Engineering and D00RS

Re: Cast String To Filter
SystemAdmin - Mon Sep 06 10:45:45 EDT 2010

Mathias' answer works exactly what I wanted..

Thanks,
Hardik Shah

Re: Cast String To Filter
Jagtattoo - Mon Dec 16 13:17:08 EST 2013

Mathias Mamsch - Mon Sep 06 10:38:05 EDT 2010
Can you set this thread to "answered" then? Regards, Mathias


Mathias Mamsch, IT-QBase GmbH, Consultant for Requirement Engineering and D00RS

Thanks for posting this thread.  I appreciate that it is searchable from Google.  I was able to use the code above to apply the modified filter that I had created as a string variable.